package com.es.easystoragesimulatedata.model;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;

/**
 * 数据来源类型枚举
 */
@Getter
@Schema(description = "数据来源类型")
public enum DataSourceType {
    
    @Schema(description = "模拟数据")
    SIMULATED("SIMULATED", "模拟数据"),
    
    @Schema(description = "手动添加")
    MANUAL_CREATED("MANUAL_CREATED", "手动添加"),
    
    @Schema(description = "手动修改")
    MANUAL_UPDATED("MANUAL_UPDATED", "手动修改");
    
    @EnumValue
    @JsonValue
    private final String code;
    
    private final String description;
    
    DataSourceType(String code, String description) {
        this.code = code;
        this.description = description;
    }
    
    /**
     * 根据 code 获取枚举
     */
    public static DataSourceType fromCode(String code) {
        for (DataSourceType type : DataSourceType.values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        return null;
    }
}

